package com.TCP_UDP网络编程.homeWork;


import java.io.*;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Scanner;

public class TCP2_client {
    static  Scanner sc  = new Scanner(System.in);
    public static void main(String[] args) throws IOException {
        String destFatherFilePath = "java-code/src/com/网络编程/接受的图片/";
        Socket socket = new Socket(InetAddress.getLocalHost(), 9997);
        OutputStream outputStream = socket.getOutputStream();
        String str;
        outputStream.write((str = sc.next()).getBytes());
        socket.shutdownOutput();

        InputStream inputStream = socket.getInputStream();
        FileOutputStream fileOutputStream = new FileOutputStream(destFatherFilePath + str + ".png");
        int readLine;
        byte[] bytes = new byte[1024];
        while((readLine =inputStream.read(bytes)) != -1 ){
            fileOutputStream.write(bytes,0,readLine);
        }
        outputStream.close();
        socket.close();
    }
}
